<template>
	<!-- 明细 -->
	<view class="">
		<u-sticky>
			<view class="mainpadding">
				<view class="flexleft"  @click="shows = true">
					<view class="titletext bold huang_text">{{start || "开始时间"}}</view>
					<view class="titletext bold huang_text">--</view>
					<view class="titletext bold huang_text">{{end || "结束时间"}}</view>
				</view>
				<view class="flexleft margin_top">
					<text class="hei_text bold main_size">我的积分:</text>
					<text class="huang_text bold main_size">{{userInfo.score}}</text>
				</view>
			</view>
		</u-sticky>
		<view class="flexcenter" style="text-align: center;margin-top: 100rpx;" v-if="list.data.length==0">
			<u-empty mode="data"></u-empty>
		</view>
		<view class="">
			<view class="bodys" v-for="(item,index) in list.data" :key="item.id">
				<view class="">
					<view class="d1">
						<view class="">{{item.memo}}</view>
						<view class="fontColor">{{item.score}}</view>
					</view>
					<view class="d2">
						<view class="">{{item.createtime_text}}</view>
					</view>
				</view>
			</view>
		</view>
		
		<!-- 开始时间选择器 -->
		<u-datetime-picker :show="shows" v-model="value1" mode="date" title="开始时间" @confirm="confirm" @cancel="shows = false">
		</u-datetime-picker>
		<!-- 结束时间选择器 -->
		<u-datetime-picker :show="showss" v-model="value2" mode="date" title="结束时间" :minDate="mindates" @confirm="confirms"
			@cancel="showss = false"></u-datetime-picker>
	</view>
</template>

<script>
	const httpRequest = require("@/commonFun/httpRequest.js");
	export default {
		data() {
			return {
				start: '',
				end: '',
				shows: false,
				showss: false,
				value1: Number(new Date()),
				value2: Number(new Date()),
				mindates: Number(new Date()),
				// 分页处理数据
				page: 1,
				limit: 12,
				list: {
					data: []
				},
				userInfo:{},
			};
		},
		onShow() {
			this.userMy()
			this.init()
		},
		methods: {
			userMy() {
				let _this = this
				httpRequest.request('/customapi/user/index', 'POST', {}).then(res => {
					if (res.code == 1) {
						this.userInfo = res.data
					} else {
						httpRequest.toast(res.msg);
					}
				})
			},
			init(isPage, page) {
				let _this = this;
				httpRequest.request('/customapi/user/scoreList', 'POST', {
					page: page || 1,
					limit: _this.limit,
					start_time: _this.start, //时间
					end_time: _this.end,
				}, false, false, true).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list.data;
						if (isPage == true) {
							_this.list.data = dataList.concat(resList.data);
						} else {
							_this.list = resList;
							_this.list.data = resList.data;
						}
					} else {
						httpRequest.toast(res.msg);
					}
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.lastpage <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			confirm(e) {
				this.shows = false;
				this.mindates = e.value
				this.start = httpRequest.returnDate(e.value);
				this.end = ""
				this.showss = true;
				this.init()
			},
			confirms(e) {
				this.showss = false;
				this.end = httpRequest.returnDate(e.value);
				this.init()
			},
		}
	};
</script>

<style lang="scss">
	/deep/.uni-date-x {
		padding: 0 !important;
	}

	.uni-date-x {
		background-color: rgb(245, 245, 245) !important;
	}

	.uni-date-x--border {
		border: none !important;
	}

	.fontColor3 {
		color: #FF516E !important;
	}

	// 订货款余额
	.bacc3 {
		background-color: #f5b15c !important;
	}

	// 预付款余额
	.bacc2 {
		background-color: #519bff !important;
	}

	// 欠款
	.bacc1 {
		background-color: #ff516e !important;
	}

	.title {
		padding: 66rpx 60rpx 34rpx 16rpx;
		text-align: center;
		font-size: 32rpx;
		background-color: #ffffff;
		color: black;

		.t1 {
			float: left;
		}
	}

	.fontColor1 {
		color: #ff516e;
	}

	.fontColor {
		color: #f5ac4f;
	}

	.bodys {
		background-color: #ffffff;
		border-bottom: 1px solid #ebebeb;
		padding: 20rpx 50rpx;

		view {

			// display: flex;
			.d1 {
				display: flex;
				justify-content: space-between;
				font-size: 32rpx;
				margin-bottom: 20rpx;
			}

			.d2 {
				display: flex;
				justify-content: space-between;
				font-size: 28rpx;
				color: #999999;
			}
		}
	}
.leftBottom {
					padding: 10rpx 20rpx;
					display: flex;
					font-size: 28rpx;

					.my {
						color: #333333;
						margin-right: 20rpx;
					}

					.price {
						color: #f5ac4f;
					}
				}
	.headerBox {
		.left {
			.time_rili {
				width: 250rpx;
				padding: 10rpx 20rpx;
				font-size: 32rpx;

				image {
					width: 26rpx;
					height: 26rpx;
					margin-left: 20rpx;
				}
			}

			.d1 {
				
			}
		}

		.right {
			width: 100rpx;
			text-align: center;
			color: #ffffff;
			padding: 15rpx 30rpx;
			border-radius: 8px;
			background-color: #f5ac4f;
		}
	}
</style>
